<div class="box box-primary">
    <div class="box-header with-border">
        <h3 class="box-title">修改课表</h3>
    </div>
    <!-- /.box-header -->
    <!-- form start -->
    <form class="form-horizontal">
        {{ csrf_field() }}
        <div class="box-body">
            <div class="form-group">
                <label class="col-sm-2 control-label" for="name">时间</label>
                <div class="col-sm-2">
                    <select class="form-control" name="weekday" id="weekday">
                        <option value="3">周三</option>
                        <option value="4">周四</option>
                        <option value="5">周五</option>
                        <option value="6">周六</option>
                        <option value="7">周日</option>
                        <option value="1">周一</option>
                        <option value="2">周二</option>
                    </select>
                </div>
            </div>
            <!-- time Picker -->
            <div class="bootstrap-timepicker">
                <div class="form-group">
                    <label class="col-sm-2 control-label">上课时间:</label>
                    <div class="input-group col-sm-4">
                        <input type="text" class="form-control timepicker" name="class_time" value="{{ $classes->class_time }}">

                        <div class="input-group-addon">
                            <i class="fa fa-clock-o"></i>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="course_age">课程年龄</label>
                <div class="col-sm-1">
                    <select class="form-control" name="course_age" id="course_age">
                        <option value="3">3岁</option>
                        <option value="4">4岁</option>
                        <option value="5">5岁</option>
                        <option value="6">6岁</option>
                        <option value="7">7岁</option>
                        <option value="8">8岁</option>
                        <option value="9">9岁</option>
                        <option value="10">10岁</option>
                        <option value="11">11岁</option>
                        <option value="12">12岁</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label" for="teacher">老师名称</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="teacher" value="{{ $classes->nice_name }}">
                    <input type="hidden" class="form-control" name="teacher_id" id="teacher_id" value="{{ $classes->teacher_id }}">
                </div>
            </div>
        </div>
        <!-- /.box-body -->

        <div class="box-footer">
            <button type="button" class="btn btn-primary" data-url="{{ url('admin/classes', $classes->id) }}" data-type="PUT" onclick="subAction(this)">提 交</button>
        </div>
    </form>
</div>
<script>
    $( function() {
        //Timepicker
        $('.timepicker').timepicker({
            minuteStep: 10,
            showMeridian: false,
            showInputs: false
        })

        //老师自动搜索
        var teachers = [];
        $.get("/admin/teacher/find",function(data){
            var obj = JSON.parse(data);
            for (y in obj){
                teachers.push(obj[y]);
            }
        });
        $( "#teacher" ).autocomplete({
            source: teachers,
            minLength: 1,
            delay: 500,
            max: 10,
            select: function (event, ui) {
                $("#teacher_id").val(ui.item.id);
            }
        });
        $("#weekday option[value='{!! $classes->weekday !!}']").attr("selected", true);
        $("#course_age option[value={!! $classes->course_age !!}]").attr("selected", true);
    } );
</script>